from django.db import models
from django_tenants.models import TenantMixin, DomainMixin

from dvadmin.utils.models import table_prefix


class Client(TenantMixin):
    name = models.CharField(max_length=100)
    paid_until = models.DateField()
    on_trial = models.BooleanField()
    created_on = models.DateField(auto_now_add=True)
    auto_create_schema = True

    def __str__(self):
        return self.name

    class Meta:
        db_table = table_prefix + "tenant_client"
        verbose_name = '租户信息'
        verbose_name_plural = verbose_name
        ordering = ('id',)


class Domain(DomainMixin):

    def __str__(self):
        return self.domain

    class Meta:
        db_table = table_prefix + "tenant_domain"
        verbose_name = '租户domain'
        verbose_name_plural = verbose_name
        ordering = ('id',)
